<template>
  <view class="content">
    <view
      v-if="payList.length > 0"
      style="background-color: #f5f5f5; height: 1rpx"
    ></view>
    <view class="boxItem" v-if="payList.length > 0">
     <!-- <view class="payitem">
        <span class="title">日期：</span>
        <span class="key">{{ pay.yearmonth }}</span>
      </view>
      <view class="payitem">
        <span class="title">姓名：</span>
        <span class="key">{{ pay.name }}</span>
      </view>
      <view class="payitem">
        <span class="title">用户工号：</span>
        <span class="key">{{ pay.user_sn }}</span>
      </view> -->
      <view v-for="item in payList" :key="item" class="payitem">
        <span class="title">{{ item.title }}：</span>
        <span class="key">{{ item.value }}</span>
      </view>
    </view>
    <u-empty
      v-if="payList.length == 0"
      mode="data"
      icon="http://cdn.uviewui.com/uview/empty/data.png"
    />
  </view>
</template>

<script>
export default {
  name: "tab-1",
  data() {
    return {
      pic: this.$IMG_URL,
      pay: {},
      payList: [],
    };
  },
  onLoad() {
    this.getGongzitiao();
  },
  methods: {
    async getGongzitiao() {
	  let data = "";	
      await this.http.get("gongzitiao/index")
	  .then((res)=>{
		  console.log("工资条接口--成功");
		  console.log(res.data);
		  data = res.data;
	  })
	  .catch((err)=>{
		 console.log("工资条接口--请求失败");
		  console.log(err);
	  });
	  	  
	  if(data == ""){
		  return;
	  };

      this.pay = data;
	  let msg = JSON.parse(data.detail)
	  let arr = []
	  for(let key in msg){
		  // if(key>=0){
			arr.push(msg[key])  
		  // }
	  }
	  this.payList = arr
      // this.payList = JSON.parse(data?.detail);
	  console.log(JSON.parse(data.detail),"999999999999");
	  console.log(arr,"999999999999");
		// if(Array.isArray(JSON.parse(data.detail))){
		// 	// 只显示工资条中isSHow为2的项
		// 	let arr = JSON.parse(data.detail);
		// 	arr.forEach((ele)=>{				
		// 		// if(ele.isShow !== 2){
		// 			this.payList.push(ele);
		// 		// }	
		// 	});	
		// };
	  
      // this.payList.map((item) => {
      //   if (item.title.indexOf("天") != -1) {
      //     item.value += " 天";
      //   } else if (item.title.indexOf("时") != -1) {
      //     item.value += " 小时";
      //   } else if (item.title == "备注") {
      //   } else {
      //     item.value += " 元";
      //   }
      // });
	  console.log("工资条接口数据");
      console.log(this.payList);
    },

  },
};
</script>
<style lang="scss" scoped>
image {
  width: 100%;
  display: block;
}
.payitem {
  display: flex;
  justify-content: space-between;
  padding-bottom: 20rpx;
  .title {
    width: 250rpx;
  }
  .key {
    width: 200rpx;
  }
}
</style>